package com.kuang.security;

import com.kuang.util.ResponseUtil;
import com.kuang.util.ResultModel;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UnAuthEntryPoint implements AuthenticationEntryPoint {

    /**
     * 权限认证失败执行的方法
     * */
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
        // ResultModel: 状态码,信息,数据
        ResponseUtil.out(response, ResultModel.error());
    }
}
